package io.renren.modules.upk.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.upk.entity.UpkBannerEntity;
import io.renren.modules.upk.service.UpkBannerService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * Banner表，保存Banner图片信息。
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-05-29 20:29:24
 */
@RestController
@RequestMapping("generator/upkbanner")
@Api("APP测试接口1")
public class UpkBannerController {
    @Autowired
    private UpkBannerService upkBannerService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("upk:upkbanner:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = upkBannerService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
//    @RequiresPermissions("upk:upkbanner:info")
    public R info(@PathVariable("id") Long id){
			UpkBannerEntity upkBanner = upkBannerService.selectById(id);

        return R.ok().put("upkBanner", upkBanner);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("upk:upkbanner:save")
    public R save(@RequestBody UpkBannerEntity upkBanner){
			upkBannerService.insert(upkBanner);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("upk:upkbanner:update")
    public R update(@RequestBody UpkBannerEntity upkBanner){
			upkBannerService.updateById(upkBanner);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("upk:upkbanner:delete")
    public R delete(@RequestBody Long[] ids){
			upkBannerService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}